package fr.ants.controller.command;

import fr.ants.view.Renderer;
import fr.ants.view.panel.Canvas;
import fr.ants.view.renderer.NodeRenderer;
import fr.ants.view.renderer.pixel.NodeGrayPixelRenderer;
import fr.ants.view.renderer.pixel.NodePixelRenderer;
import fr.ants.view.renderer.pokemon.NodePokemonRenderer;

/**
 * To delete a graphic component in the map.
 * 
 * @author Guillaume Ruscassie
 * 
 */
public class SetRendererCommand implements Command {

	/**
	 * Canvas.
	 */
	private Canvas canvas;



	/**
	 * Build.
	 * 
	 * @param clock
	 *            clock.
	 */
	public SetRendererCommand() {
	}

	/**
	 * To Set the type of renderer
	 * 
	 * @author Guillaume Ruscassie, Jordan ENSFELDER
	 * 
	 */
	@Override
	public void execute() {
		if (canvas!=null) {
			Renderer type = canvas.getRenderer();
			NodeRenderer nr;
			
			switch (type){ 
			case POKEMON :
				nr = new NodePokemonRenderer();
				break;
			case GRIS:
				nr = new NodeGrayPixelRenderer();
				break;
			case RELIEF:
				nr = new NodePixelRenderer();
				break;
			default:
				nr = new NodePokemonRenderer();
				break;
			}
			canvas.setNodeRenderer(nr);
			canvas.repaint();
		}
	}

	/**
	 * We need the canvas to execute this command.
	 * 
	 * @param canvas
	 *            canvas
	 */
	public void setCanvas(final Canvas canvas) {
		this.canvas = canvas;
	}

}
